    <div class="row">
		  <div class="col-xs-6 col-md-3">
		    
		  </div>
		  <div class="col-xs-6 col-md-9">
		  		<button onclick="currency_add();" class="btn btn-success pull-right">新增</button>
		  </div>
		</div>
          <div class="table-responsive">
            <table class="table table-striped">
              <thead>
                <tr>
                  <th width="100">排序</th>
                  <th>名称</th>
                  <th>简称</th>
                  <th>符号</th>
                  <th width="150">操作</th>
                </tr>
              </thead>
              <tbody>
              	<?php foreach ($list as $item):?>
                  <tr id="currency_<?=$item['id']?>">
                      <td><input class="currency_sort" style="border:none" location_id="<?=$item['id']?>" location_mark="<?=$item['order']?>" type="number" value="<?=$item['order']?>" min=0 max=1000 /></td>
                      <td><?=$item['name']?></td>
                      <td><?=$item['short']?></td>
                      <td><?=$item['symbol']?></td>
                      <td>
                          <div class="btn-group" role="group" aria-label="...">
                            <button type="button" onclick="currency_edit(<?=$item['id']?>);" class="btn btn-primary btn-sm">编辑</button>
                            <button type="button" onclick="currency_delete(<?=$item['id']?>);" class="btn btn-danger btn-sm">删除</button>
                          </div>
                      </td>
                  </tr>
              <?php endforeach;?>
              </tbody>
            </table>
          </div>
    
 <script type="text/javascript">
$(function(){
    $('.currency_sort').blur(function(){
      var input = $(this);
      var newVal = input.val();
      var oldVal = input.attr('location_mark');
      var id = input.attr('location_id');
      if(newVal!=oldVal){
        var loading = layer.load(1, {
          shade: [0.5,'#000']
        });
        $.post('',{order:newVal,id:id},function(result){
          if(result.statu=='ok'){
            location.reload();
          }else{
            layer.close(loading);
            layer.msg(result.message, {icon: 2});
            input.val(oldVal);
          }
        },'json')
      }
    })
 })

function currency_delete(id){
  var confirm = layer.confirm('确定删除？', {
    btn: ['确定','取消'] //按钮
  }, function(){
    layer.close(confirm);
    var loading = layer.load(1, {
      shade: [0.5,'#000']
    });
    $.post('',{id:id},function(result){
      if(result.statu=='ok'){
        location.reload();
      }else{
        layer.close(loading);
        layer.msg(result.message, {icon: 2});
      }
    },'json')
  });
}

function currency_form(data){
  if(!data) data = {name:'',short:'',symbol:''};
  var html = '<form id="currency_form">';
  if(data.id) html+='<input type="hidden" name="id" value="'+data.id+'" />';
  html+=makeInput({name:'name',label:'货币名称',value:data.name});
  html+=makeInput({name:'short',label:'简称',value:data.short});
  html+=makeInput({name:'symbol',label:'符号',value:data.symbol});
  html+='</form>';
  return html;
}

function currency_edit(id){
  var $td = $('#currency_'+id).children('td');
  var data = {id:id};
  data.name = $td.eq(1).text();
  data.short = $td.eq(2).text();
  data.symbol = $td.eq(3).text();
  var html = currency_form(data);
  $.alert('修改货币',html,function(modal){
    var formData = $("#currency_form").serializeJson();
    formData.name = $.trim(formData.name);
    if(formData.name.length<1||formData.name.length>20){
      $('#alert_form_name').formTip('货币名称长度为1-20！','error',false);
      return
    }
    if(formData.short.length<1||formData.short.length>5){
      $('#alert_form_short').formTip('简称长度为1-5！','error',false);
      return
    }
    if(formData.symbol.length!=1){
      $('#alert_form_symbol').formTip('符号长度为1！','error',false);
      return
    }
    var loading = layer.load(1, {
      shade: [0.5,'#000']
    });
    $.post('',formData,function(result){
      if(result.statu=='ok'){
        location.reload()
      }else{
        layer.close(loading);
        layer.msg(result.message, {icon: 2});
      }
    })
    modal.modal('hide');
  },function(modal){
    modal.modal('hide');
  });  
}


function currency_add(){
  var html = currency_form();
  $.alert('增加货币',html,function(modal){
    var formData = $("#currency_form").serializeJson();
    formData.name = $.trim(formData.name);
    if(formData.name.length<1||formData.name.length>20){
      $('#alert_form_name').formTip('货币名称长度为1-20！','error',false);
      return
    }
    if(formData.short.length<1||formData.short.length>5){
      $('#alert_form_short').formTip('简称长度为1-5！','error',false);
      return
    }
    if(formData.symbol.length!=1){
      $('#alert_form_symbol').formTip('符号长度为1！','error',false);
      return
    }
    var loading = layer.load(1, {
      shade: [0.5,'#000']
    });
    $.post('',formData,function(result){
      if(result.statu=='ok'){
        location.reload()
      }else{
        layer.close(loading);
        layer.msg(result.message, {icon: 2});
      }
    })
    modal.modal('hide');
  },function(modal){
    modal.modal('hide');
  });
}

</script>
        